<?php
$currentPage = $pages->getCurrentPage()+1;
?>
<!-- BEGIN PAGE CONTAINER-->
<div class="container-fluid">
    <!-- BEGIN PAGE HEADER-->
    <div class="row-fluid">
        <div class="span12">
            <!-- BEGIN PAGE TITLE & BREADCRUMB-->
            <h3 class="page-title">
                Quản lý đơn hàng
            </h3>
            <ul class="breadcrumb">
                <li>
                    <i class="icon-home"></i>
                    <a href="index.html">Trang chủ</a>
                    <i class="icon-angle-right"></i>
                </li>
                <li><a href="#">Quản lý đơn hàng</a></li>
            </ul>
            <!-- END PAGE TITLE & BREADCRUMB-->
        </div>
    </div>
    <!-- END PAGE HEADER-->
    <!-- BEGIN PAGE CONTENT-->
    <div class="row-fluid">
        <div class="span12">
            <!-- BEGIN EXAMPLE TABLE PORTLET-->
            <div class="portlet box light-grey">
                <div class="portlet-title">
                    <h4><i class="icon-th-list"></i>Danh sách đơn hàng</h4>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                </div>
                <div class="portlet-body">
                    <div class="clearfix">
                        <div class="btn-group pull-right delete-order">
                            <button class="btn red" type="button">
                                Xóa <i class="icon-trash"></i>
                            </button>
                        </div>
                    </div>
                    <?php if(Yii::app()->user->hasFlash('message')):?>
                        <div class="alert alert-success">
                            <?php echo Yii::app()->user->getFlash('message'); ?>
                        </div>
                    <?php endif; ?>
                    <table class="table table-striped table-bordered table-hover" id="sample_1">
                        <thead>
                        <tr>
                            <th width="30">Stt</th>
                            <th style="width:8px;"><input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes" /></th>
                            
                            <th>Transaction ID</th>
                            <th>Khách hàng</th>
                            <th>Ngày</th>
                            <th>Payment Method</th>
                            <th>Tổng</th>
                            <th>Trạng thái <a href="#"><i class="icon-save"></i></a></th>
                            
                            <th>Chi tiết</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php $i = 1;
                        foreach ($model as $key => $data) { ?>
                        <tr class="<?php if($i / 2) { echo 'odd'; } else { echo 'even';}?> gradeX">
                            <td><?php echo $i; $i++;?></td>
                            <td><input type="checkbox" class="checkboxes ckb-del" value="<?php echo $data->order_id;?>" /></td>
                            <td><?php echo $data->transaction_id;?></td>
                            <td><?php echo $data->customer->email?></td>
                            <td><?php echo $data->ordering_date;?></td>
                            <td><?php echo $data->paymentMethod->title;?></td>
                            <td><?php echo $data->getTotalPrice()?> usd</td>
                            <td>
                                <select rel="<?php echo $data->order_id;?>" style="width:120px" name="Order[status][]" class="update-order-status">
                                    <option value="1" <?php if($data->status == 1) { echo 'selected="selected"';}?>>Chờ xác nhận</option>
                                    <option value="2" <?php if($data->status == 2) { echo 'selected="selected"';}?>>Xác nhận</option>
                                    <option value="3" <?php if($data->status == 3) { echo 'selected="selected"';}?>>Đã hủy</option>
                                    <option value="4" <?php if($data->status == 4) { echo 'selected="selected"';}?>>Trả lại</option>
                                    <option value="5" <?php if($data->status == 5) { echo 'selected="selected"';}?>>Đã giao hàng</option>
                                    <option value="6" <?php if($data->status == 6) { echo 'selected="selected"';}?>>Đã thanh toán</option>
                                    <option value="7" <?php if($data->status == 7) { echo 'selected="selected"';}?>>Hoàn tất</option>
                                </select>
                            </td>
                            <td><a href="/admin/order/detail/id/<?php echo $data->order_id;?>"><i class="icon-print"></i></a></td>
                        </tr>
                        <?php } ?>
                        </tbody>
                    </table>
                    <?php if(count($model) > 0) {?>
                        <div class="row-fluid">
                            <div class="span6">
                                <!--<div class="dataTables_info" id="sample_1_info">Hiển thị 1 đến 2 của 2 kết quả</div>-->
                                <div class="dataTables_info" id="sample_1_info">Hiển thị <?php echo $pages->getCurrentPage()*$page_size+1;?> đến <?php echo ($item_count >= (($pages->getCurrentPage()+1) * $page_size))?($pages->getCurrentPage()+1) * $page_size : $item_count;?> của <?php echo $item_count?> kết quả</div>
                            </div>
                            <div class="span6">
                                <div class="dataTables_paginate paging_bootstrap pagination">
                                    <?php
                                    // the pagination widget with some options to mess
                                    $this->widget('MyLinkPager', array(
                                        'currentPage' => $pages->getCurrentPage(),
                                        'itemCount' => $item_count,
                                        'pageSize' => $page_size,
                                        'maxButtonCount' => 5,
                                        'header' => '',
                                        'htmlOptions' => array('class' => 'pages'),
                                    ));
                                    ?>
                                </div>
                            </div>
                        </div>
                    <?php }?>
                </div>
            </div>
            <!-- END EXAMPLE TABLE PORTLET-->
        </div>
    </div>

    <!-- END PAGE CONTENT-->
</div>
<!-- END PAGE CONTAINER-->
